<template>
  <div class="chart-dialog">
    <div class="chart-bg">
      <div class="title-box">
        <div class="title-content">
          <span class="title">{{ titleName }}</span>
          <div class="tabs" v-if="titleName == '杨家门避灾点'">
            <div class="right-box" :class="titleTypes == item.val ? 'active' : ''" v-for="(item, index) in titleList"
              :key="index" @click="onTitleChange">
              <span>{{ item.label }}</span>
            </div>
          </div>
        </div>

        <div class="close-btn" @click="onClickCloseBtn">
          <img src="../../assets/imgs/close.png" alt="关闭" />
        </div>
      </div>
      <div class="content-box">
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, onMounted } from "vue";
const props = defineProps({
  titleName: {
    type: String,
    default: ""
  },
  titleType: {
    type: String,
    default: "1"
  },
})
const titleTypes = ref('1')
onMounted(() => {
  titleTypes.value = props.titleType;
})
const titleList = [{
  val: '1',
  label: '责任人'
},
{
  val: '2',
  label: '物资'
}];
const onTitleChange = () => {
  if (titleTypes.value == "1") {
    titleTypes.value = "2";
  } else if (titleTypes.value == "2") {
    titleTypes.value = "1";
  }
  emits("changeTitle", titleTypes.value);
};
const emits = defineEmits(["closeChartDialog", 'changeTitle']);
function onClickCloseBtn() {
  emits("closeChartDialog", {});
}
</script>

<style lang="less" scoped>
.chart-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9990;

  .chart-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 40%;
    background: url(../../assets/imgs/dialogBg.png) no-repeat center;
    background-size: 100% 100%;

    .title-box {
      position: absolute;
      left: 3%;
      top: 2.4%;
      width: calc(100% - 6%);
      height: 38px;
      // border: 1px solid red;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .title-content {
        display: flex;
        align-items: center;

        .title {
          font-family: "YSBTH";
          color: #fff;
          font-size: 30px;
          margin-right: 10px;
        }

        .tabs {
          height: 38px;
          display: flex;
          align-items: center;

          .right-box {
            width: 60px;
            height: 30px;
            line-height: 30px;
            cursor: pointer;
            text-align: center;
            font-size: 14px;
            background: url(../../assets/img/noActiveImg.png) no-repeat center;
            margin-left: 10px;
            color: #4c6b85;
          }

          .right-box.active {
            background: url(../../assets/img/activeImg.png) no-repeat center;
            color: #79a5c7;
          }
        }

      }

      .close-btn {
        width: 24px;
        cursor: pointer;

        img {
          display: block;
          width: 100%;
        }
      }
    }

    .content-box {
      position: absolute;
      left: 3%;
      top: calc(2.4% + 40px);
      width: calc(100% - 6%);
      height: 30vh;
      // border: 1px solid aqua;
      font-family: 'PingFangReg';
      font-size: 20px;

      :deep(.el-tabs__item) {
        color: #fff;
      }

      :deep(.el-tabs__item:hover) {
        color: #409eff;
      }

      :deep(.el-tabs__item.is-active) {
        color: #409eff;
      }
    }
  }
}
</style>
